package com.subsequent.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsequent.pojo.Campuses;
import com.subsequent.service.CampusesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/campuses")
public class CampusesController {
    @Autowired
    private CampusesService campusesService;

    @GetMapping("/list")
    public Page<Campuses> list(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "10") int pageSize,
            @RequestParam(required = false) String campusName,
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime
    ) {
        return campusesService.pageQuery(pageNum, pageSize, campusName, status, startTime, endTime);
    }
}